/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package server.entity;

import java.io.Serializable;
import java.util.Collection;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 *
 * @author USER
 */
@Entity
@Table(name = "Photo", catalog = "WebPhotoShare", schema = "dbo")
@NamedQueries({
    @NamedQuery(name = "Photo.findAll", query = "SELECT p FROM Photo p"),
    @NamedQuery(name = "Photo.findByPhotoID", query = "SELECT p FROM Photo p WHERE p.photoID = :photoID"),
    @NamedQuery(name = "Photo.findByPhotoName", query = "SELECT p FROM Photo p WHERE p.photoName = :photoName"),
    @NamedQuery(name = "Photo.findByServerFile", query = "SELECT p FROM Photo p WHERE p.serverFile = :serverFile"),
    @NamedQuery(name = "Photo.findByDescriptions", query = "SELECT p FROM Photo p WHERE p.descriptions = :descriptions"),
    @NamedQuery(name = "Photo.findByTag", query = "SELECT p FROM Photo p WHERE p.tag = :tag"),
    @NamedQuery(name = "Photo.findByUploaddate", query = "SELECT p FROM Photo p WHERE p.uploaddate = :uploaddate"),
    @NamedQuery(name = "Photo.findByStatus", query = "SELECT p FROM Photo p WHERE p.status = :status"),
    @NamedQuery(name = "Photo.findByViews", query = "SELECT p FROM Photo p WHERE p.views = :views"),
    @NamedQuery(name = "Photo.findByDownloads", query = "SELECT p FROM Photo p WHERE p.downloads = :downloads")})
public class Photo implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue
    @Basic(optional = false)
    @Column(name = "PhotoID", nullable = false)
    private Integer photoID;
    @Basic(optional = false)
    @Column(name = "PhotoName", nullable = false, length = 15)
    private String photoName;
    @Basic(optional = false)
    @Column(name = "ServerFile", nullable = false, length = 50)
    private String serverFile;
    @Basic(optional = false)
    @Column(name = "Descriptions", nullable = false, length = 50)
    private String descriptions;
    @Basic(optional = false)
    @Column(name = "Tag", nullable = false, length = 50)
    private String tag;
    @Basic(optional = false)
    @Column(name = "uploaddate", nullable = false)
    @Temporal(TemporalType.TIMESTAMP)
    private Date uploaddate;
    @Basic(optional = false)
    @Column(name = "status", nullable = false)
    private boolean status;
    @Basic(optional = false)
    @Column(name = "views", nullable = false)
    private long views;
    @Basic(optional = false)
    @Column(name = "downloads", nullable = false)
    private long downloads;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "photo")
    private Collection<ViewPhoto> viewPhotoCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "photo")
    private Collection<Comment> commentCollection;
    @JoinColumn(name = "username", referencedColumnName = "Username", nullable = false)
    @ManyToOne(optional = false)
    private RegisteredUser registeredUser;
    @JoinColumn(name = "CollectionID", referencedColumnName = "CollectionID", nullable = false)
    @ManyToOne(optional = false)
    private Category category;

    public Photo() {
    }

    public Photo(Integer photoID) {
        this.photoID = photoID;
    }

    public Photo(Integer photoID, String photoName, String serverFile, String descriptions, String tag, Date uploaddate, boolean status, long views, long downloads) {
        this.photoID = photoID;
        this.photoName = photoName;
        this.serverFile = serverFile;
        this.descriptions = descriptions;
        this.tag = tag;
        this.uploaddate = uploaddate;
        this.status = status;
        this.views = views;
        this.downloads = downloads;
    }

    public Integer getPhotoID() {
        return photoID;
    }

    public void setPhotoID(Integer photoID) {
        this.photoID = photoID;
    }

    public String getPhotoName() {
        return photoName;
    }

    public void setPhotoName(String photoName) {
        this.photoName = photoName;
    }

    public String getServerFile() {
        return serverFile;
    }

    public void setServerFile(String serverFile) {
        this.serverFile = serverFile;
    }

    public String getDescriptions() {
        return descriptions;
    }

    public void setDescriptions(String descriptions) {
        this.descriptions = descriptions;
    }

    public String getTag() {
        return tag;
    }

    public void setTag(String tag) {
        this.tag = tag;
    }

    public Date getUploaddate() {
        return uploaddate;
    }

    public void setUploaddate(Date uploaddate) {
        this.uploaddate = uploaddate;
    }

    public boolean getStatus() {
        return status;
    }

    public void setStatus(boolean status) {
        this.status = status;
    }

    public long getViews() {
        return views;
    }

    public void setViews(long views) {
        this.views = views;
    }

    public long getDownloads() {
        return downloads;
    }

    public void setDownloads(long downloads) {
        this.downloads = downloads;
    }

    public Collection<ViewPhoto> getViewPhotoCollection() {
        return viewPhotoCollection;
    }

    public void setViewPhotoCollection(Collection<ViewPhoto> viewPhotoCollection) {
        this.viewPhotoCollection = viewPhotoCollection;
    }

    public Collection<Comment> getCommentCollection() {
        return commentCollection;
    }

    public void setCommentCollection(Collection<Comment> commentCollection) {
        this.commentCollection = commentCollection;
    }

    public RegisteredUser getRegisteredUser() {
        return registeredUser;
    }

    public void setRegisteredUser(RegisteredUser registeredUser) {
        this.registeredUser = registeredUser;
    }

    public Category getCategory() {
        return category;
    }

    public void setCategory(Category category) {
        this.category = category;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (photoID != null ? photoID.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Photo)) {
            return false;
        }
        Photo other = (Photo) object;
        if ((this.photoID == null && other.photoID != null) || (this.photoID != null && !this.photoID.equals(other.photoID))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "server.entity.Photo[photoID=" + photoID + "]";
    }

}
